package com.ijtunes;

import com.ijtunes.utils.Properties;
import com.ijtunes.filetypes.Track;
import java.util.ArrayList;

public class ReplacementTags {

    private ArrayList<ReplacementTagGroup> groups = new ArrayList<ReplacementTagGroup>();

    public ReplacementTags(ArrayList<String> values) {
        for (String value : values) {
            groups.add(new ReplacementTagGroup(value));
        }
    }

    public String checkReplaceTag(Track track, String tag) {
        String tempTag = tag;
        for (ReplacementTagGroup group : groups) {
            if (group.check(track, tag)) {
                tempTag = group.getTag();
            }
        }
        return tempTag;
    }

    public String toPropertyString() {
        String result = "";
        for (int i = 0; i < groups.size(); i++) {
            if (i != 0) {
                result += Properties.DELIM;
            }
            result += groups.get(i).toPropertyString();
        }
        return result;
    }
}
